<template>
  <div class="login">
    <div class="login-con">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <login-form @on-success-valid="handleSubmit"></login-form>
          <p class="login-tip">输入任意用户名和密码即可</p>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import LoginForm from '_c/login-form'
import { mapActions } from 'vuex'
export default {
  components: {
    LoginForm
  },
  methods: {
    ...mapActions([
      'handleLogin',
      'getUserInfo'
    ]),
    async handleSubmit ({ userName, password }) {
      await this.handleLogin({ userName, password })
      await this.getUserInfo()
      this.$router.push({
        name: this.$config.homeName
      })
    }
  }
}
</script>

<style lang="less">
.login{
  width: 100%;
  height: 100%;
  position: relative;
  &-con{
    position: relative;
    top: 20%;
    width: 300px;
    margin: 0 auto;
    box-shadow: 0 0 10px 2px rgba(0,0,0,0.2);
    border-radius: 12px;
    &-header{
      font-size: 16px;
      font-weight: 300;
      text-align: center;
      padding: 30px 0;
    }
    .form-con{
      padding: 10px 0 0;
    }
    .login-tip{
      font-size: 10px;
      text-align: center;
      color: #c3c3c3;
    }
  }
}
</style>
